package com.testfileupload.uploadimg.design.single;

/**
 * 枚举方式单例
 * 能够避免多线程同步问题，也可反序列化创建新对象
 */
public class SingleModel7 {
    public static void main(String[] args) {
        Single6 instence = Single6.INSTENCE;
        Single6 instence1 = Single6.INSTENCE;
        instence.sayOk();
        System.out.println(instence==instence1);

    }
}

enum Single6 {
    INSTENCE;

    public void sayOk() {
        System.out.println("say ok");
    }
}
